#include "PrivateWindow.h"

PrivateWindow::PrivateWindow(HINSTANCE hInstance, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu)
{
	this->hInstance = hInstance;
	this->WindowClassName = lpWindowName;
	RegisterWindowClass();
	hWnd = ::CreateWindow(WindowClassName,lpWindowName,dwStyle,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance, NULL);
	SetWindowLongPtr(hWnd,0,(long)this);
}
PrivateWindow::~PrivateWindow()
{
}

ATOM PrivateWindow::RegisterWindowClass()
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc = WndProc;
	wcex.cbClsExtra = 0;
	wcex.cbWndExtra = sizeof(ChatWindow*);
	wcex.hInstance = hInstance;
	wcex.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW);
	wcex.lpszMenuName = NULL;
	wcex.lpszClassName = WindowClassName;
	wcex.hIconSm = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));
	
	return RegisterClassEx(&wcex);
}

VOID PrivateWindow::SendTheMessage()
{
	MESSAGE privateMessage;

	GetDlgItemText(hFormView,IDC_MESSAGE,privateMessage.text,TEXT_SIZE);
	if (_tcscmp(privateMessage.text,TEXT("")))
	{
		SendPrivateMessage(privateMessage.text);
		SetDlgItemText(hFormView,IDC_MESSAGE,TEXT(""));
	}
}
VOID PrivateWindow::CloseWindow()
{
	FinishConversation();
}